Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to proxy arbitrary K8s APIs #21

Merged
merged 1 commit into from
May 4, 2023

Conversation

antoninbas
Copy link
Contributor

@antoninbas antoninbas commented Apr 26, 2023

We add a new API endpoint which proxies GET requests to the K8s api-server. This removes the need to define custom APIs for each use case that requires directly retrieving data from the K8s API. At the moment we can use this API for the web client "Summary" page, which displays information from the AntreaAgentInfo and AntreaControllerInfo CRs. As a result, the specialized "/info" endpoint is now deprecated, and will be removed in the near future (July 2023).

The list of API resources being proxied is determined by:

  1. a global variable in the backend code; if a client attempts to access
    an API that is not being proxied, the "Not Found" status code will be
    returned. Same if the HTTP verb being used is not GET.
  2. K8s RBAC permissions for the antrea-ui backend; the list / get verbs
    must be granted for the resources being proxied.

We use the Go standard library reverse proxy implementation. Note that the implementation was greatly improved in Go 1.20, but we currently use Go 1.19 for all Antrea projects.

Fixes #10

We add a new API endpoint which proxies GET requests to the K8s
api-server. This removes the need to define custom APIs for each use
case that requires directly retrieving data from the K8s API. At the
moment we can use this API for the web client "Summary" page, which
displays information from the AntreaAgentInfo and AntreaControllerInfo
CRs. As a result, the specialized "/info" endpoint is now deprecated,
and will be removed in the near future (July 2023).

The list of API resources being proxied is determined by:

1) a global variable in the backend code; if a client attempts to access
   an API that is not being proxied, the "Not Found" status code will be
   returned. Same if the HTTP verb being used is not GET.
2) K8s RBAC permissions for the antrea-ui backend; the list / get verbs
   must be granted for the resources being proxied.

We use the Go standard library reverse proxy implementation. Note that
the implementation was greatly improved in Go 1.20, but we currently use
Go 1.19 for all Antrea projects.

Fixes antrea-io#10

Signed-off-by: Antonin Bas <[email protected]>
Copy link
Member

@tnqn tnqn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@antoninbas antoninbas merged commit 0884569 into antrea-io:main May 4, 2023
@antoninbas antoninbas deleted the proxy-arbitrary-k8s-apis branch May 4, 2023 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a generic proxy API to backend to get / list CRs
2 participants